<!DOCTYPE HTML>
<html lang="en">
<head>
<title>DriveGet - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The DriveGet command retrieves various types of information about the computer's drive(s)." />
<meta name="ahk:equiv-v2" content="commands/Drive.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>DriveGet</h1>

<p>Retrieves various types of information about the computer's drive(s).</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, <a href="#SubCommands">SubCommand</a> <span class="optional">, Value</span></pre>
<p>The <em>OutputVar</em> parameter is the name of the variable in which to store the result. The <em>SubCommand</em> and <em>Value</em> parameters are dependent upon each other and their usage is described below.</p>

<h2 id="SubCommands">Sub-commands</h2>
<p>For <em>SubCommand</em>, specify one of the following:</p>
<ul>
    <li><a href="#List">List</a>: Retrieves a string of letters, one character for each drive letter in the system.</li>
    <li><a href="#Capacity">Capacity</a>: Retrieves the total capacity of the specified path in megabytes.</li>
    <li><a href="#FileSystem">FileSystem</a>: Retrieves the type of the specified drive's file system.</li>
    <li><a href="#Label">Label</a>: Retrieves the volume label of the specified drive.</li>
    <li><a href="#Serial">Serial</a>: Retrieves the volume serial number of the specified drive.</li>
    <li><a href="#Type">Type</a>: Retrieves the drive type of the specified path.</li>
    <li><a href="#Status">Status</a>: Retrieves the status of the specified path.</li>
    <li><a href="#StatusCD">StatusCD</a>: Retrieves the media status of a CD or DVD drive.</li>
</ul>

<h3 id="List">List</h3>
<p>Retrieves a string of letters, one character for each drive letter in the system. For example: ACDEZ.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, List <span class="optional">, Type</span></pre>
<p>If <em>Type</em> is omitted, all drive types are retrieved. Otherwise, <em>Type</em> should be one of the following words to retrieve only a specific type of drive: CDROM, REMOVABLE, FIXED, NETWORK, RAMDISK, UNKNOWN.</p>

<h3 id="Capacity">Capacity</h3>
<p>Retrieves the total capacity of <em>Path</em> (e.g. <code>C:\</code>) in megabytes.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, Capacity, Path</pre>
<p>Use <a href="DriveSpaceFree.htm">DriveSpaceFree</a> to determine the free space. The word Cap can be used in place of Capacity.</p>

<h3 id="FileSystem">FileSystem</h3>
<p>Retrieves the type of <em>Drive</em>'s file system.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, FileSystem, Drive</pre>
<p><em>Drive</em> is the drive letter followed by a colon and an optional backslash, or a UNC name such <code>\\server1\share1</code>. <em>OutputVar</em> will be set to one of the following words: FAT, FAT32, NTFS, CDFS (typically indicates a CD), UDF (typically indicates a DVD). <em>OutputVar</em> will be made blank and <a href="../misc/ErrorLevel.htm">ErrorLevel</a> set to 1 if the drive does not contain formatted media. The word FS can be used in place of FileSystem.</p>

<h3 id="Label">Label</h3>
<p>Retrieves <em>Drive</em>'s volume label.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, Label, Drive</pre>
<p><em>Drive</em> is the drive letter followed by a colon and an optional backslash, or a UNC name such <code>\\server1\share1</code>. To change the label, follow this example: <code><a href="Drive.htm">Drive</a>, Label, C:, MyLabel</code>.</p>

<h3 id="Serial">Serial</h3>
<p>Retrieves <em>Drive</em>'s volume serial number expressed as decimal integer.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, Serial, Drive</pre>
<p><em>Drive</em> is the drive letter followed by a colon and an optional backslash, or a UNC name such <code>\\server1\share1</code>. See <a href="SetFormat.htm">SetFormat</a> for how to convert it to hexadecimal.</p>

<h3 id="Type">Type</h3>
<p>Retrieves <em>Path</em>'s drive type.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, Type, Path</pre>
<p><em>OutputVar</em> is set to one of the following words: Unknown, Removable, Fixed, Network, CDROM, RAMDisk.</p>

<h3 id="Status">Status</h3>
<p>Retrieves <em>Path</em>'s status.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, Status, Path</pre>
<p><em>OutputVar</em> is set to one of the following words: Unknown (might indicate unformatted/RAW), Ready, NotReady (typical for removable drives that don't contain media), Invalid (<em>Path</em> does not exist or is a network drive that is presently inaccessible, etc.)</p>

<h3 id="StatusCD">StatusCD</h3>
<p>Retrieves the media status of a CD or DVD drive.</p>
<pre class="Syntax"><span class="func">DriveGet</span>, OutputVar, StatusCD <span class="optional">, Drive</span></pre>
<p><em>Drive</em> is the drive letter followed by a colon. If <em>Drive</em> is omitted, the default CD/DVD drive will be used. <em>OutputVar</em> is made blank if the status cannot be determined. Otherwise, it is set to one of the following strings:</p>
<table class="info">
    <tr>
        <td style="width:15%">not ready</td>
        <td>The drive is not ready to be accessed, perhaps due to being engaged in a write operation. Known limitation: &quot;not ready&quot; also occurs when the drive contains a DVD rather than a CD.</td>
    </tr>
    <tr>
        <td>open</td>
        <td>The drive contains no disc, or the tray is ejected.</td>
    </tr>
    <tr>
        <td>playing</td>
        <td>The drive is playing a disc.</td>
    </tr>
    <tr>
        <td>paused</td>
        <td>The previously playing audio or video is now paused.</td>
    </tr>
    <tr>
        <td>seeking</td>
        <td>The drive is seeking.</td>
    </tr>
    <tr>
        <td>stopped</td>
        <td>The drive contains a CD but is not currently accessing it.</td>
    </tr>
</table>
<p>This sub-command will probably not work on a network drive or non-CD/DVD drive; if it fails in such cases or for any other reason, <em>OutputVar</em> is made blank and <a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1.</p>
<p>If the tray was recently closed, there may be a delay before the sub-command completes.</p>
<p>To eject or retract the tray, see the <a href="Drive.htm">Drive</a> command.</p>

<h2>Error Handling</h2>
<p><span class="ver">[v1.1.04+]</span>: This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if there was a problem or 0 otherwise.</p>

<h2>Remarks</h2>
<p>Some of the sub-commands will accept a network share name as <em>Path</em> or <em>Drive</em>, such as <code>\\MyServer\MyShare\</code>.</p>

<h2>Related</h2>
<p><a href="Drive.htm">Drive</a>, <a href="DriveSpaceFree.htm">DriveSpaceFree</a></p>

<h2>Examples</h2>

<div class="ex" id="ExAnalyzeDrive">
<p><a href="#ExAnalyzeDrive">#1</a>: Allows the user to select a drive in order to analyze it:</p>
<pre>FileSelectFolder, folder,, 3, Pick a drive to analyze:
if not folder
    return
DriveGet, list, List
DriveGet, cap, Capacity, %folder%
DriveSpaceFree, free, %folder%
DriveGet, fs, FileSystem, %folder%
DriveGet, label, Label, %folder%
DriveGet, serial, Serial, %folder%
DriveGet, type, Type, %folder%
DriveGet, status, Status, %folder%
MsgBox All Drives: %list%`nSelected Drive: %folder%`nDrive Type: %type%`nStatus: %status%`nCapacity: %cap% M`nFree Space: %free% M`nFilesystem: %fs%`nVolume Label: %label%`nSerial Number: %serial%</pre>
</div>

</body>
</html>
